<template>
  <div>
    <header class="header">
      <div class="title">
        <img src="../../assets/images/01_11.png" alt class="img_zuo" @click="back" />
        <div>任务{{rwjbDwType==0?'接收':'下发'}}</div>
        <div class="btn-chakan" @click="toCkrw">查看任务</div>
      </div>
    </header>
    <div class="up"></div>
    <div class="contents">
      <div class="main_top">
        <div class="tits">
			<div style="display: inline-block;text-align: justify;padding: 0 0.092592rem;">{{ data.name }}</div>
		</div>
        <div class="all">
          <tr>
            <td style="height: 100%;display: flex;border-bottom: none;">
              <div class="kuangt" style="width: 2.48rem;height: 100%;">具体任务名称</div>
            </td>
          </tr>
          <div class="nice" id="nice">
            <table>
              <thead>
              <tr>
                <td v-for="(item, index) in dataList" :key="index">
                  <div style="height: 100%;"
                    class="tit_width"
                    :class="{'onlyOne':dataList.length === 1}">
                    <div style="display: inline-block;text-align: justify;padding: 0 0.092592rem;">{{ item }}</div>
                    </div>
                </td>
              </tr>
              </thead>
            </table>
          </div>
        </div>
        <div style="display:flex" class="tjb">
          <div class="lefts" id="lefts">
            <table>
              <tr v-for="(item, index) in contentList" :key="index">
                <td>
                  <div class="kuangt">{{ item }}</div>
                </td>
              </tr>
            </table>
          </div>
        <div class="rights" id="rights" @scroll="add()">
          <table>
            <tr class="titit">
              <td
                @click="jumpTable(data.id, item.id)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.单位 ? item.单位 : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td v-for="(item, index) in data.spcialTaskDecVos" :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.工作落实 ? item.工作落实 : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.风险研判)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.风险研判 ? item.风险研判.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.安排部署)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.安排部署 ? item.安排部署.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.安全培训)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.安全培训 ? item.安全培训.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.桌面推演)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.桌面推演 ? item.桌面推演.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.实战演练)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.实战演练 ? item.实战演练.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.警示约谈)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.警示约谈 ? item.警示约谈.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.隐患协调)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.隐患协调 ? item.隐患协调.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.现场安全宣传)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.现场安全宣传 ? item.现场安全宣传.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.入户安全宣传)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.入户安全宣传 ? item.入户安全宣传.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id, item.网络安全宣传)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.网络安全宣传 ? item.网络安全宣传.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="toXcpc(data.id, item.id,item.巡查排查)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.巡查排查 ? item.巡查排查 : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id,item.报刊宣传)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.报刊宣传 ? item.报刊宣传.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="jumpDeployment(data.id, item.id,item.督促整改)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.督促整改 ? item.督促整改.num : 0 }}</div>
              </td>
            </tr>
            <tr class="titit">
              <td
                @click="toRwzj(data.id, item.id,item.任务总结)"
                v-for="(item, index) in data.spcialTaskDecVos"
                :key="index">
                <div
                  class="tit_width"
                  :class="{'onlyOne':data.spcialTaskDecVos&&data.spcialTaskDecVos.length==1}">
                  {{ item.任务总结 ? item.任务总结 : 0 }}</div>
              </td>
            </tr>
          </table>
        </div>
      </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      userId: 0,
      rwjbDwType: 0,
      id: 0,
      data: {},
      dataList: [],
      contentList: ['单位', '工作落实', '风险研判', '安排部署', '安全培训', '桌面推演', '实战演练', '警示约谈',
        '隐患协调', '现场安全宣传', '入户安全宣传', '网络安全宣传', '巡查排查','报刊宣传','督促整改','任务总结']
    };
  },
  methods: {
    back(){//返回
      // this.$router.push("/rwjb_list");
      this.$router.back()
    },
    //  查询数据
    query () {
      let that = this;
      let params = {
        userId: this.userId,
        theNewTaskAssignId: that.id,
        isPostOrGet: this.rwjbDwType
      };
      /*params = {
        userId: 2932,
        theNewTaskAssignId: 273,
        isPostOrGet: 1
      }*/
      that.axios.get(`${that.$global_msg.Url.host}/taskAssign/zcrwtj`,
        { params }).then(res => {
          console.log(res);
          this.data = res.data.rows[0];
          this.dataList=[]
          this.data.spcialTaskDecVos.map(res => {
            this.dataList.push(res.名称)
          })
      })
    },
    //  跳转宣传部署
    jumpDeployment (id, ids, data) {
      var t = $(".rights").scrollTop()
        console.log("距离：", t)
        sessionStorage.setItem("table_list_scroll", t)
      if (data !== undefined) {
        if(data.num && data.num > 0){
          localStorage.setItem('rwjb_taskSpecialId', ids);
          localStorage.setItem('rwjb_theNewTaskAssignId', id);
          localStorage.setItem('deploymentId', data.id);
          // sessionStorage.setItem("where",1)
          this.$router.push({
            path: '/xcbs_rwjb'
          });
        }
      }
    },
    toCkrw(){
      var t = $(".rights").scrollTop()
        console.log("距离：", t)
        sessionStorage.setItem("table_list_scroll", t)
      this.$router.push({
        path: '/ckrw',
        query: { id:this.id,type:'专项任务' }
      });
    },
    //  跳转街道名称页面
    jumpTable (id, ids) {

      var t = $(".rights").scrollTop()
        console.log("距离：", t)
        sessionStorage.setItem("table_list_scroll", t)
      localStorage.setItem('rwjb_taskSpecialId', ids);
      localStorage.setItem('rwjb_theNewTaskAssignId', id);
      this.$router.push({
        path: 'table_listtwo',
      });
    },
    //  跳转巡查排查页面
    toXcpc(id, ids,xunchaNum){
      var t = $(".rights").scrollTop()
        console.log("距离：", t)
        sessionStorage.setItem("table_list_scroll", t)
      if(xunchaNum && xunchaNum > 0){
        localStorage.setItem('rwjb_taskSpecialId', ids);
        localStorage.setItem('rwjb_theNewTaskAssignId', id);
        this.$router.push("/community_list_rwjb");
      }
    },
    toRwzj(id, ids,rwzjNum){
      var t = $(".rights").scrollTop()
        console.log("距离：", t)
        sessionStorage.setItem("table_list_scroll", t)
      if(rwzjNum && rwzjNum > 0){
        localStorage.setItem('rwjb_taskSpecialId', ids);
        localStorage.setItem('rwjb_theNewTaskAssignId', id);
        this.$router.push("/list_rwzj");
      }
    },
    list() {
      var h_gao = window.screen.height;
      var w_kuan = window.screen.width / 10;
      h_gao = h_gao - (278 / 54) * w_kuan;
      $(".tjb").css({ height: h_gao + "px" });

    },
    add(ev) {
        console.log()
        var a = document.getElementById("rights").scrollTop;
        var b = document.getElementById("rights").scrollLeft;
        document.getElementById("lefts").scrollTop = a;
        document.getElementById("nice").scrollLeft = b;
      }
  },
  created(){
            // window.addEventListener('scroll', this.add,true);
  },
  beforeRouteEnter(to, from, next) {
      console.log(from)
      next((vm) => {
        vm.$nextTick(function () {
          vm.id = localStorage.getItem("rwjbId")?JSON.parse(localStorage.getItem("rwjbId")):null;
        vm.userId = localStorage.getItem('userId')
        vm.rwjbDwType = localStorage.getItem('rwjbDwType')
          if (from.path == "/rwjb_list" || from.path == "/") {
            vm.list();
            vm.query();
          } else {
            // vm.init();
            setTimeout(() => {
              this.$nextTick(() => {
                // document.querySelector('#app').scrollTop = this.offsetTop;
                $(".rights").scrollTop(sessionStorage.getItem("table_list_scroll"))
              });
            }, 10)
          }
        });

      });
    },

  mounted(){
    var _this = this;

    // this.list();
    // this.query();

    //物理返回
    // window.addEventListener("popstate", function(){
    //   _this.back();
    // }, false);
  }
};
</script>
<style  scoped>
* {
  color: #ffffff;
}
.header {
  height: 1.8519rem;
  background: #007aff;
  padding-top: 0.8333rem;
  box-sizing: border-box;
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 20;
  font-size: 0.388888rem;
}

.title {
  padding: 0 0.3704rem;
  display: flex;
  align-items: center;
  color: #fff;
  position: relative;
}

.title > div {
  width: 100%;
  font-size: 0.4444rem;
  text-align: center;
}

.img_zuo {
  width: 0.2593rem;
  height: 0.463rem;
}
.btn-chakan {
  position: absolute;
  right: 0.462962rem;
  font-size: 0.388888rem !important;
  bottom: 0;
  width: auto !important;
  height: 100%;
  display: flex;
  align-items: center;
}
.found {
  display: inline-block;
  margin-right: 0.37037rem;
}
.up {
  padding-top: 2.037037rem;
}
table {
  border: 1px solid #ffffff;
  color: #ffffff;
  border-collapse: collapse;
  text-align: center;
}
th {
  height: 0.925926rem;
  margin-top: 1.111111rem;
  border: 1px solid #ffffff;
}
td {
    height: 1.111111rem;
  border: 1Px solid #ffffff;
  border-right: none;
  /* border-bottom: none; */
}
.main_top{
  background: #7ac0fe;
}
.contents {
  /* border-radius: 0.185185rem; */
  border-radius:.37037rem;
  overflow: hidden;
  margin: 0 .37037rem;
  box-sizing: border-box;
}
.tits {
  text-align: center;
  color: #ffffff;
  padding-top: 0.185185rem;
  font-size: 0.407407rem;
  margin-bottom: 0.185185rem;
}
.left {
  width: 1.851852rem;
  text-align: center;
  color: #ffffff;

}
.kuangt {
  width: 2.5rem;
  height: 1.111111rem;
  text-align: center;
  color: #ffffff;
  overflow: hidden;
  z-index: 10;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tit_width {
  width: 3.333rem;
  height: 1.111111rem;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nice {
  display: inline-block;
  /*width: 6.851852rem;*/
  flex: 1;
  overflow: hidden;
  box-sizing: border-box;
}
.lefts{
    overflow: hidden;
    box-sizing: border-box;
     z-index: 100;
     /* border-right: 1PX solid #ffffff; */
}
.rights{
    width: 6.851852rem;
    overflow-x: auto;
}
.all{
    display: flex;

}

.onlyOne{
	width: 6.766rem !important;
}

</style>
